package com.superhelper.superhelper_web.domain;

import java.util.HashMap;
import java.util.Map;

/**
 * 　分页mode
 * 
 * @author Administrator
 *
 */

public class PageModel {

	// 当前页数
	private int pageIndex;
	// 一页显示的数量
	private int pageSize = 10;
	// 记录总条数
	private int recordCount;

	// 查询条件
	private Map<String, String> queryMap = new HashMap<String, String>();

	public int getPageIndex() {
		return pageIndex <= 1 ? 1 : pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getPageSize() {
		return pageSize <= 0 ? 2 : pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getRecordCount() {
		return recordCount;
	}

	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}

	/**
	 * 获取开始行数
	 * 
	 * @return
	 */
	public int getStartRow() {
		setPageIndex(getPageIndex() >= getPageCount() ? getPageCount()
				: getPageIndex());
		return (getPageIndex() - 1) * getPageSize();
	}

	/**
	 * 获取总页数
	 * 
	 * @return
	 */
	public int getPageCount() {
		return (recordCount % getPageSize() == 0) ? recordCount / getPageSize()
				: (recordCount / getPageSize()) + 1;
	}

	public Map<String, String> getQueryMap() {
		return queryMap;
	}

	public void setQueryMap(Map<String, String> queryMap) {
		this.queryMap = queryMap;
	}

}